package com.itheima.controller;

import com.itheima.domain.entity.Experience;
import com.itheima.service.ExperienceService;
import com.itheima.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.sql.SQLException;
import java.util.List;

@RestController
@Api(tags = "经验相关的接口")
@RequestMapping("/experience")
@Slf4j
public class ExperienceController {
    @Autowired
    private ExperienceService experienceService;
    /**
     * 获取全部岗位经验数据
     * @return
     */
    @GetMapping("/total")
    @ApiOperation("获取全部岗位经验数据")
    public Result<List<Experience>> total(){
        List<Experience> result= experienceService.total();
        return Result.success(result);
    }
    /**
     * 获取岗位经验数据
     * @return
     */
    @GetMapping("/category")
    @ApiOperation("获取岗位经验数据")
    public Result<List<Experience>> category(String category) throws SQLException {
        log.info("category={}", category);
        List<Experience> result= experienceService.category(category);
        return Result.success(result);
    }
}
